<?php

function news_5_cols_shortcode( $atts, $content = null ) {
	
	extract(shortcode_atts(array(
		"category" => '',
		"post_limit" => '',
		"title" => '',
		"bottom" => '',
	), $atts));
	
	global $wp_query,$paged,$post;
	$temp = $wp_query;
	$wp_query= null;
	$wp_query = new WP_Query();
	
	if( $atts['post_limit'] ) { $query .= '&posts_per_page=' . $atts['post_limit']; }
	if( $atts['category'] ) { $query .= '&category_name=' . $atts['category']; }
	if( $atts['title'] ) { $title = $atts['title']; } else { $title = __('All','qns'); }
	
	if(!empty($query)){
		$query .= $query;
	} ?>
	
	<?php $wp_query->query($query);
	ob_start();
	?>
	
	<div class="title-block">
		<h3><?php echo $title; ?></h3>
	</div>
	
	<?php if( $atts['bottom'] == 'true' ) { 
		echo '<ul class="news-block-columns-5 clearfix" style="margin: 0 !important;">';
	} else {
		echo '<ul class="news-block-columns-5 clearfix">';
	} ?>
	
		<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
			<?php get_template_part( 'loop', 'style4' ); ?>
		<?php endwhile; ?>
	
	</ul>
	
	<?php $wp_query = null; $wp_query = $temp;
	$content = ob_get_contents();
	ob_end_clean();
	return $content;
	
}

add_shortcode( 'news_5_cols', 'news_5_cols_shortcode' );

?>